package edu.sygyzy.controller;

import edu.sygyzy.entity.Employee;
import edu.sygyzy.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/employees") // 确保路径正确
public class EmployeeController {
    @Autowired
    private EmployeeService service;

    @GetMapping
    public List<Employee> list() {
        return service.findAll();
    }

    @PostMapping
    public void save(@RequestBody Employee employee) {
        service.save(employee);
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable Integer id) {
        service.delete(id);
    }

    @PutMapping("/{id}")
    public void update(@RequestBody Employee employee){ service.update(employee);}
}
